const path = require('path')
const webpack = require('webpack')
const HtmlWebpackPlugin = require("html-webpack-plugin");

const resolve = p => path.resolve(__dirname, p)
const srcDir = resolve('src')
const distDir = resolve('dist')

module.exports = {
  mode: 'development',
  devtool: 'source-map',
  context: srcDir,
  entry: './main.js',
  output: {
    filename: '[name].bundle.js',
    chunkFilename: '[name].chunk.js',
    path: distDir
  },
  plugins: [
    new HtmlWebpackPlugin({
      title: 'Redux Demo',
      template: resolve('src/index.html'),
      filename: resolve('dist/index.html')
    })
  ],
  devServer: {
    static: distDir,
    host: 'localhost',
    port: 8309,
    hot: true,
    historyApiFallback: true
  }
}
